<template>
  <div>
    <x-header :right-options="{showMore: true}" @on-click-more="showMenus = true">IXA汇添盈号</x-header>
    <div class="productDetailBox">
      <h3>{{financialData.name}}</h3>
      <div class="chart">
        <div class="item red">
          <strong>{{financialData.rate}}5.12%</strong>
          <span>预期收益率</span>
        </div>
        <div class="item">
          <strong>{{financialData.term}}30天</strong>
          <span>投资期限</span>
        </div>
      </div>
      <div class="chartInfo">
        <dfn class="progressBar">
          <i></i>
        </dfn>
        <div>
          <p class="left"><span>进度 {{financialData.availableCredit}}%</span><span>剩余额度 {{financialData.totalAmountOfPurchase}}小于500万</span></p>
        </div>
        <!-- <p class="left">进度 {{financialData.availableCredit}}% 剩余额度 {{financialData.totalAmountOfPurchase}}小于500万</p> -->
      </div>
    </div>
    <p class="line"><span>4级-高风险</span><span>股票型</span><span>5000起购</span></p>
    <div class="chartProgress">
      <flow>
        <flow-state class="step1">
          <h4 slot="title" style="text-align: left">起售</h4>
          <span slot="title">{{financialData.openSaleDate}}</span>
        </flow-state>
        <flow-line></flow-line>

        <flow-state class="step2">
          <h4 slot="title">截止</h4>
          <span slot="title">{{financialData.cutOffDate}}</span>
        </flow-state>
        <flow-line></flow-line>

        <flow-state class="step3">
          <h4 slot="title">起立日</h4>
          <span slot="title">{{financialData.interestDate}}</span>
        </flow-state>
        <flow-line></flow-line>

        <flow-state class="step4">
          <h4 slot="title" style="text-align: right">到期</h4>
          <span slot="title">{{financialData.dueDate}}</span>
        </flow-state>
      </flow>
    </div>
    <div class="holiday"><p>*到期时间如果是节假日，则在节假日后的第一个工作日到期</p></div>
    <div><p class="trade">交易规则</p></div>
    <div><p class="trade">存续期间，每天9：30-22：30办理申购。</p></div>
    <div><p class="trade">每个理财产品计划到期后本金分红自动赎回到账，本金和分红将在到期后工作日返回</p></div>
    <group>
        <cell title="产品说明" link="PrerecordMain" class="cell">
          <!-- <img slot="icon" style="width:.44rem;display:block;margin-right:.28rem;" src="../../assets/img/PreRecord/close.png"> -->
        </cell>
        <cell title="公告及风险提示" link="PrerecordInquire" class="cell">
          <!-- <img slot="icon" style="width:.44rem;display:block;margin-right:.28rem;" src="../../assets/img/PreRecord/open.png"> -->
        </cell>
      </group>
<div class="button">
  <div class="dy-footer">
<p class="bottom"><span>关注</span><span>距结束还剩：</span><span>立即购买</span></p>
</div>
</div>
    <!-- <x-button class="subBtn" type="primary" action-type="button" @click.native='gotoNext()'>{{buttonTxt}}</x-button> -->
  </div>
</template>

<script>

export default {
  data () {
    return {
      financialData: {
        name: '', // 理财产品名
        rate: '', // 年化收益率
        profit: '', // 年化收益额
        term: '', // 投资期限
        availableCredit: '', // 剩余额度
        totalAmountOfPurchase: '', // 可购总额度
        remainingTime: '', // 还剩xx天购买
        openSaleDate: '', // 开售日
        cutOffDate: '', // 截止日
        interestDate: '', // 起息日
        dueDate: '', // 到期日
        list: {
          subTime: '', // 认购期
          productName: '', // 产品名称
          productType: '', // 产品类型
          currency: '', // 计价币种
          deliveryTime: '', // 产品交收日期
          expireTime: '', // 产品到期日期
          minBuyMoney: '', // 最低购买金额
          increaseMoney: '', // 递增金额
          saveBook: '', // 是否保本
          RiskGrade: '' // 风险等级
        }},
      buttonTxt: '购买' // 判断获得： 1.购买；2.去开户
    }
  },
  methods: {
    getFinancialData () {
      let _this = this
      window.WebViewJavascriptBridge.callHandler('nativeRequest',
        JSON.stringify({
          'requstSource': 'internetRequest',
          'url': 'http://whichat.icitic.net/mstep/mstep.do?act=business',
          'params': {'method_Name': 'showProDetail', 'user_Data': {'productId': '3015'}}
        }),
        function (response) {
          response = JSON.parse(response)
          if (response.status === 0 || response.status === '0') {
            _this.financialData = response.data.data[0]
          } else {
            console.log('fail')
          }
        })
    },
    gotoNext () {
      this.$router.push({name: 'FinancialShift'})
    }
  },
  created () {
    this.getFinancialData()
  }
}
</script>
<style>
button.subBtn {
  background-color: #ec1b30;
}
button.weui-btn_primary:not(.weui-btn_disabled):active {
  background: rgba(236,27,48,.6);
}
div.weui-wepay-flow, .weui-wepay-flow-auto {
  padding: .3rem .3rem 1rem;
}
div.step1 .weui-wepay-flow__title-bottom {
  top: 20px;
  left: 0;
  -webkit-transform: translate(0, 0);
  transform: translate(0, 0);
}
div.step4 .weui-wepay-flow__title-bottom {
  top: 20px;
  left: auto;
  right: 0;
  -webkit-transform: translate(0, 0);
  transform: translate(0, 0);
}
div.step1 .weui-wepay-flow__state, div.step2 .weui-wepay-flow__state {
  background-color: #3d477b;
}
div.step3 .weui-wepay-flow__state {
  background-color: #8fc31f;
}
div.step4 .weui-wepay-flow__state {
  background-color: #f63;
}
div.weui-wepay-flow__li {
  width: 9px;
  height: 9px;
}
div.weui-wepay-flow__li .weui-wepay-flow__state {
  width: 9px;
  height: 9px;
  line-height: 9px;
}
</style>

<style lang="less" scoped>
.productDetailBox {
  width: 100%;
  height: 3.4rem;
  background-color: #3d477b;
  color: #fff;
  h3 {
    padding: .3rem .3rem 0;
    height: .6rem;
    font-size: .28rem;
  }
  .chart {
    margin-top: .3rem;
    padding: 0 .14rem .3rem;
    display: flex;
    .item {
      flex: 1;
      padding: 0 .16rem;
      border-right: 1px solid #bfbfbf;
      strong {
        // todo 此处需要用到 PingFang-SC-Bold 字体
        display: block;
        font-weight: normal;
        font-size: .4rem;
      }
      span {
        display: block;
        font-size: .2rem;
      }
    }
    :last-child {
      border-right: 0 none;
    }
    & .red {
      color: #f63;
    }
  }
  .button{
display: flex;
padding: .4rem .3rem;
}
  .chartInfo {
    padding: .1rem .3rem 0;
    dfn {
      position: relative;
      display: block;
      height: .16rem;
      background-color: rgba(255,255,255,.5);
      border-radius: .04rem;
      i {
        position: absolute;
        width: 2.4rem;
        height: .16rem;
        border-radius: .04rem;
        background-color: rgba(255,255,255,1);
      }
    }
    p {
      margin-top: .2rem;
      font-size: .2rem;
    }
  }
}
.detailInfo {
  margin-top: .2rem;
  padding: 0 .3rem .2rem;
  background-color: #fff;
  h2 {
    font-size: .3rem;
    line-height: .8rem;
    border-bottom: 1px solid #eaeaea;
    font-weight: bold;
  }
  .detailMain {
    padding: .16rem 0;
    dl {
      display: flex;
      line-height: .6rem;
      dt {
        width: 2.2rem;
        color: #999;
      }
      dd {
        flex: 1;
        text-align: right;
      }
    }
  }
}
.left{
    display:flex;
    justify-content: space-between;
    padding: 0 .5rem;
  }
.line{
    display:flex;
    justify-content: space-between;
    padding: 0 .5rem;
    border-bottom: 1px solid #333;
  }
  .bottom{
    // display:flex;
    // justify-content: space-between;
    // padding: 0 .5rem;
    display: flex;
    justify-content: space-between;
    padding: 0 .5rem;
  }
.right{
  padding-right: .2rem
}
.trade{
  padding-left: .2rem
}
.dy-footer{
      position: absolute;
      left: 0;
      bottom: 0;
      overflow: hidden;
      width: 100%;
      .buy-button{
        padding: 0.2rem 0.4rem 0.2rem;
        border-top: .01rem solid #d9d9d9;
        background-color: #fff;
        .weui-btn:after{
          /*border: none;*/
        }
      }
    }
.holiday{
    font-size: .26rem;
    text-align: center;
    padding-bottom: .3rem
}

.chartProgress {
  line-height: 1;
  p {
    font-size: .26rem;
    padding: .35rem .3rem 0;
    text-align: right;
    font-weight: normal;
    color: #f63;
  }
  h4 {
    font-size: .2rem;
    font-weight: bold;
    color: #333;
  }
  span {
    font-size: .18rem;
    color: #999;
  }
}
</style>
